<#include "/common/head.ftl">

<@showTitle title="${i18n.getMessage('offering')} > ${i18n.getMessage('searchResult')}">
	<ul class="linksMenu">
		<li><a href="#" onclick="selectAll()">${i18n.getMessage('Select All')}</a></li>
		<li>-</li>
		<li class="sub"><a href="#">${i18n.getMessage('printing')}</a>
			<ul>
				<li><a href="#" onclick="printFollowUpBookCover()">${i18n.getMessage('printing.followUpCover')}</a></li>
				<li><a href="#" onclick="printStudentPerformanceForm()">${i18n.getMessage('printing.studentPerformance')}</a></li>
			</ul>
        </li>
        <li>-</li>
		<li><a href="#" onclick="cc('offering/showSearchOffering.sgt')">${i18n.getMessage('search')}</a></li>
	</ul>
</@showTitle>

<br/>

<form id="form" onreset="$('error').hide()" method="POST">
<@display.table id="listTable" name="offerings" sort="list" defaultorder="descending" defaultsort="6" pagesize="50">
	<@display.column title="${i18n.getMessage('select')}" class="w050 center"><input type="checkbox" name="ids" value="${(listTable.id)!}"/></@display.column>
	<@display.column title="${i18n.getMessage('name')}" property="name" href="offering/showInfoOffering.sgt" paramId="id" paramProperty="id" sortable="true"></@display.column>
	<@display.column title="${i18n.getMessage('room')}" property="room.code" href="materialFacilities/showInfoRoom.sgt" paramId="id" paramProperty="room.id" sortable="true"></@display.column>
	<@display.column title="${i18n.getMessage('shift')}" sortable="true" style="text-align:center">${(listTable.shift.startTime?time)!}-${(listTable.shift.endTime?time)!}</@display.column>
	<@display.column title="${i18n.getMessage('startDate')}" property="startDate" format="{0, date, ${i18n.getMessage('format.date')}}" sortable="true" style="text-align:center"></@display.column>
	<@display.column title="${i18n.getMessage('endDate')}" property="endDate" format="{0, date, ${i18n.getMessage('format.date')}}" sortable="true" style="text-align:center"></@display.column>
</@display.table>
</form>

<br/><br/>


<script>
selectAll = function() {
	var form = $('form');
	var count = 0;
	form.getInputs('checkbox').each(function(input) {
		if(input.checked)
			count++;
	});
	if(count > 0) {
		form.getInputs('checkbox').each(function(input) {
			input.checked = false;
		});
	}
	else {
		form.getInputs('checkbox').each(function(input) {
			input.checked = true;
		});
	}
}

printFollowUpBookCover = function() {
	var form = $('form');
	form.action = 'offering/printFollowUpBookCover.sgt';
	form.target = "_blank";
	form.submit();
}

printStudentPerformanceForm = function() {
	var form = $('form');
	form.action = 'offering/printStudentPerformanceForm.sgt';
	form.target = "_blank";
	form.submit();
}
</script>